
# The American Viewer: Political Consequences of Entertainment Media
# Eunji Kim and Shawn Patterson Jr 
# American Political Science Review 
# Replication File [Appendix G Table G1]

library(tidyverse)

cces2016_issue <- read.csv("appendix_tableg1.csv")

issues <- c("import_gaymarriage", "import_guncontrol", "import_abortion", 
            "import_taxes", "import_immigration", "import_deficit", 
            "import_defense", "import_socialsecurity", "import_environment", 
            "import_jobs", "import_crime", "import_nationalsecurity", 
            "import_racerelations", "import_healthcare", "import_corruption")

issue_candidate <- cces2016_issue %>% group_by(primary_pref) %>% 
  summarise_at(vars(issues), mean) %>% 
  filter(! primary_pref %in% c('Another Democrat','Hillary Clinton','Bernie Sanders','Someone else who is not a Democrat or Republican')) %>% 
  drop_na() %>% t() %>% row_to_names(row_number = 1) %>% as.data.frame() %>% 
  select(`Donald Trump`,`Ted Cruz`,`John Kasich`,`Another Republican`,`Marco Rubio`) %>% 
  mutate_all(as.numeric) %>% arrange(-`Donald Trump`)

issue_candidate
